<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>高德地图查询</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
</head>

<body>
    <div class="search">
        <button id="GoMark"> 标注</button>
        <input type="text" id='intext' name="">
        <button id="butseach">搜索</button>
    </div>
    <div id="GdList">
    </div>
</body>

</html>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=b924bdcb52ba818af5dc34c21ba657fa&plugin=AMap.PlaceSearch"></script>
<!-- <script type="text/javascript" src="http://cache.amap.com/lbs/static/PlaceSearchRender.js"></script> -->
<script type='text/javascript' src='../js/zepto.min.js' charset='utf-8'></script>
<script type="text/javascript">
window.onload = function() {
        var intext = document.getElementById('intext');
        var butseach = document.getElementById('butseach');
        var GdList = document.getElementById('GdList');

        eflower_GdMap.GdSearchload();

        butseach.onclick = function() {

            var val = intext.value;

            eflower_GdMap.GdSearch(val, GdList);
        }
    }

        var sub_index=1;
        var arrays=new Array();
        $(document).on('click','#GdList li',function(){
            $(this).attr('lg');
            var data={
                  icon: 'http://webapi.amap.com/theme/v1.3/markers/n/mark_b'+ sub_index +'.png',
                  position: [ $(this).attr('lg').split(',')[0], $(this).attr('lg').split(',')[1]]
            }
            arrays.push(data)
            sub_index++;
            console.log(arrays)
        })

        //页面跳转
        $(document).on('click','#GoMark',function(){
            console.log(arrays)
            localStorage.setItem('mark',JSON.stringify( arrays))
            window.location.href="Maker.html"
        })




    // function GdSearchload(){
    //  	var Lbody = document.body;
    //  	var LO = document.createElement("div");
    //  			LO.style.display='none';
    //  	    LO.setAttribute('id', 'MarkMap');
    //  	    Lbody.appendChild(LO);
    //  	var src = document.createElement('script')
    //  	    src.setAttribute('type', 'text/javascript');
    //  			src.setAttribute('src', 'http://webapi.amap.com/maps?v=1.3&key=b924bdcb52ba818af5dc34c21ba657fa&plugin=AMap.PlaceSearch');
    //  			Lbody.appendChild(src);
    //  	var sce = document.createElement('script')
    // 	    sce.setAttribute('type', 'text/javascript');
    // 			sce.setAttribute('src', 'http://cache.amap.com/lbs/static/PlaceSearchRender.js');
    // 			 Lbody.appendChild(sce);
    // }
    // function GdSearch(val,idmode) {

// 			var map = new AMap.Map("MarkMap");
// 			var placeSearchOptions = { //构造地点查询类
// 			    pageSize: 100,
// 			    pageIndex: 1
// 			};  
//       var placeSearch = new AMap.PlaceSearch(placeSearchOptions);
//      placeSearch.search(val, callback);
//      var placeSearchRender = new Lib.AMap.PlaceSearchRender();
//      function callback(status, result) {
//          console.log(result);
//          if (status === 'complete' && result.info === 'OK') {
//              var data = result.poiList.pois
//              var Oul=document.createElement('ul');
//              		 Oul.style.listStyle="none";
//              		 Oul.style.margin="10px";
//              		 Oul.style.padding="0px";

//                // $.each(data, function(i, v)
//                 for(var i = 0; i < data.length; i++){
//                    if (data[i].type !='地名地址信息;普通地名;地市级地名' && data[i].type !='地名地址信息;普通地名;省级地名'  && data[i].type != '地名地址信息;普通地名;区县级地名') {
//                    	 var Li = document.createElement("div");
//                    	     Li.style.height = '35px'; 
//                    	     Li.style.width = '100%';
//                    	     Li.style.paddingLeft = '10px';
//                    	     Li.style.lineHeight = '35px'; 
//                    	     Li.style.borderBottom = '1px solid #e5e5e5'; 
//                    	 		 Li.setAttribute('lg',data[i].location.lng+','+ data[i].location.lat);
//                    	 		 Li.innerHTML = data[i].name;
//                    	 		 Oul.appendChild(Li);
//                    }
//                };
//                idmode.appendChild(Oul);

//          } else {
//              alert('查无数据！！')
//          }
//      }
// }
//}



// eflower_GdMap = {
//         GdSearchload: function() {
//             var Lbody = document.body;
//             var LO = document.createElement("div");
//             LO.style.display = 'none';
//             LO.setAttribute('id', 'MarkMap');
//             Lbody.appendChild(LO);
//             var sce = document.createElement('script')
//             sce.setAttribute('type', 'text/javascript');
//             sce.setAttribute('src', 'http://cache.amap.com/lbs/static/PlaceSearchRender.js');
//             Lbody.appendChild(sce);
//         },
//         GdSearch: function(val, idmode) {
//             var map = new AMap.Map("MarkMap");
//             var placeSearchOptions = { //构造地点查询类
//                 pageSize: 100,
//                 pageIndex: 1
//             };
//             var placeSearch = new AMap.PlaceSearch(placeSearchOptions);
//             placeSearch.search(val, callback);
//             var placeSearchRender = new Lib.AMap.PlaceSearchRender();

//             function callback(status, result) {
//                 if (status === 'complete' && result.info === 'OK') {
//                     var data = result.poiList.pois
//                     var Oul = document.createElement('ul');
//                     Oul.style.listStyle = "none";
//                     Oul.style.margin = "10px";
//                     Oul.style.padding = "0px";
//                     for (var i = 0; i < data.length; i++) {
//                         if (data[i].type != '地名地址信息;普通地名;地市级地名' && data[i].type != '地名地址信息;普通地名;省级地名' && data[i].type != '地名地址信息;普通地名;区县级地名') {
//                             var Li = document.createElement("li");
//                             Li.style.height = '35px';
//                             Li.style.width = '100%';
//                             Li.style.paddingLeft = '10px';
//                             Li.style.lineHeight = '35px';
//                             Li.style.borderBottom = '1px solid #e5e5e5';
//                             Li.setAttribute('lg', data[i].location.lng + ',' + data[i].location.lat);
//                             Li.innerHTML = data[i].name;
//                             Oul.appendChild(Li);
//                         }
//                     };
//                     idmode.appendChild(Oul);
//                 } else {
//                     alert('查无数据！！')
//                 }
//             }

//         }
//     }
    //初始化业务加载 搜索插件，自定义div map;
    //eflower_GdMap.GdSearchload();
    //第一个传值是搜索的内容 第二个查询出来的数据的接收容器
    //eflower_GdMap.GdSearch(val,GdList);

eflower_GdMap={GdSearchload:function(){var e=document.body,a=document.createElement("div");a.style.display="none";a.setAttribute("id","MarkMap");e.appendChild(a);a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src","http://cache.amap.com/lbs/static/PlaceSearchRender.js");e.appendChild(a)},GdSearch:function(e,a){new AMap.Map("MarkMap");(new AMap.PlaceSearch({pageSize:100,pageIndex:1})).search(e,function(e,g){if("complete"===e&&"OK"===g.info){var d=g.poiList.pois,
f=document.createElement("ul");f.style.listStyle="none";f.style.margin="10px";f.style.padding="0px";for(var b=0;b<d.length;b++)if("\u5730\u540d\u5730\u5740\u4fe1\u606f;\u666e\u901a\u5730\u540d;\u5730\u5e02\u7ea7\u5730\u540d"!=d[b].type&&"\u5730\u540d\u5730\u5740\u4fe1\u606f;\u666e\u901a\u5730\u540d;\u7701\u7ea7\u5730\u540d"!=d[b].type&&"\u5730\u540d\u5730\u5740\u4fe1\u606f;\u666e\u901a\u5730\u540d;\u533a\u53bf\u7ea7\u5730\u540d"!=d[b].type){var c=document.createElement("li");c.style.height="35px";
c.style.width="100%";c.style.paddingLeft="10px";c.style.lineHeight="35px";c.style.borderBottom="1px solid #e5e5e5";c.setAttribute("lg",d[b].location.lng+","+d[b].location.lat);c.innerHTML=d[b].name;f.appendChild(c)}
GdList.innerHTML="";a.appendChild(f);}else alert("\u67e5\u65e0\u6570\u636e\uff01\uff01")});new Lib.AMap.PlaceSearchRender}};



</script>
